package com.yugao.fintech.antelope.mps.config;

import com.yugao.fintech.antelope.mps.api.constatnts.MsgPushMqCons;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.retry.MessageRecoverer;
import org.springframework.amqp.rabbit.retry.RepublishMessageRecoverer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitErrorConfig {
    @Autowired
    private RabbitTemplate rabbitTemplate;


    /**
     * 消息重试一定次数后，用特定的routingKey转发到指定的交换机中，方便后续排查和告警
     */
    @Bean
    public MessageRecoverer messageRecoverer() {
        return new RepublishMessageRecoverer(rabbitTemplate, MsgPushMqCons.MSG_PUSH_ERROR_EXCHANGE, MsgPushMqCons.MSG_PUSH_ERROR_KEY);
    }
}
